package com.lcj.crawler;

import com.geccocrawler.gecco.pipeline.Pipeline;
import com.lcj.service.CompanyRecruitInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SaveDxrcContactPipeline implements Pipeline<DxrcContactPage> {

    @Resource(name="companyRecruitInfoServiceImpl")
    private CompanyRecruitInfoService companyRecruitInfoService;
    @Override
    public void process(DxrcContactPage dxrcContactPage) {
        String recruitUrl = dxrcContactPage.getRequest().getUrl();
        String workPlace = "";
        String contactPerson = "";
        String phone="";
        String industryName ="";
        String persons = "";
        String address = "";
        if(dxrcContactPage.getWorkPlace()!=null){
            workPlace = dxrcContactPage.getWorkPlace();
        }
        if(dxrcContactPage.getContactPerson()!=null){
            contactPerson = dxrcContactPage.getContactPerson();
        }
        if(dxrcContactPage.getPhone()!=null){
            phone = dxrcContactPage.getPhone();
        }
        if(dxrcContactPage.getIndustryName()!=null){
            industryName = dxrcContactPage.getIndustryName();
        }
        if(dxrcContactPage.getPersons()!=null){
            persons = dxrcContactPage.getPersons();
        }
        if(dxrcContactPage.getAddress()!=null){
            address = dxrcContactPage.getAddress();
        }
        companyRecruitInfoService.updateDxrc(recruitUrl,workPlace,contactPerson,phone,industryName,persons,address);
    }
}
